import express from 'express'
import { PrismaClient } from '@prisma/client'
// import { PrismaClient } from '../generated/prisma'

const prisma = new PrismaClient()

const app = express()

app.post('/create',async (req,res) => {
  const {name,email} = req.body
  await prisma.user.create({
    data:{
      name,
      email,
      posts: {
        create: [
          {
            title: 'Post 1',
            content: 'Content 1',
          },
          {
            title: 'Post 2',
            content: 'Content 2',
          }
        ]
      }
    }
  })
  res.json({message:'User created'})
})


app.listen(3000, async () => {
  console.log('Server is running on port 3000');
})
